<?php
$exam_status = array('' => '状态', 2 => '上传数据', 1 => "归档",3=>'阅卷');
?>
<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>    
    <div class="clearfix back_bgf border_3 border_c pt20 pr30 pb20 height32 fontc_666">
        <form class="clearfix pb10" action="<?php echo $this->createUrl('index'); ?>" method="get">
            <table>
                <tbody>
                    <tr>
                        <td align="right" width="98" class="pt10 pr3 pb10">学年：</td>
                        <td width="120" class="pt10 pb10">                                
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter select_shelter2"> 
                                    <select class="fl fontc_666" name="exam_term_id">
                                        <option value="0">请选择</option>
                                        <?php if (!empty($info['eduTermData'])): ?>
                                            <?php foreach ($info['eduTermData'] as $ev): ?>
                                                <option value="<?php echo $ev['term_start_year']; ?>~<?php echo $ev['term_end_year']; ?>" <?php if (!empty($search['exam_term_id'])): echo ($search['exam_term_id'] == $ev['term_start_year'].'~'.$ev['term_end_year']) ? 'selected' : ''; endif; ?>>
                                                <?php echo $ev['term_start_year']; ?>~<?php echo $ev['term_end_year']; ?>
                                                </option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                        <td align="right" width="75" class="pt10 pr3 pb10">学期：</td>
                        <td width="160" class="pt10 pb10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter select_shelter2"> 
                                    <select class="fl fontc_666" name="exam_term_sx">
                                        <option value="0">请选择</option>
                                        <option value="s" <?php echo (!empty($search['exam_term_sx']) && $search['exam_term_sx'] == 's') ? 'selected' :'';?>>第一学期</option>
                                        <option value="x" <?php echo (!empty($search['exam_term_sx']) && $search['exam_term_sx'] == 'x') ? 'selected' :'';?>>第二学期</option>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                        <td align="right" width="75" class="pt10 pr3 pb10">项目名称：</td>
                        <td width="120" class="pt10 pb10">                            
                            <input type="text" name="exam_name" value="<?php echo (!empty($search['exam_name'])) ? $search['exam_name'] : '';?>" id="exam_name" class="w100 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666" />
                        </td>
                        <td width="150" class="pt10 pb10 text_right">
                            <input type="submit" value="查询" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
                        </td>
                    </tr>
                    <tr>
                        <td  align="right"class="pt10 pr3">考试日期：</td>
                        <td colspan="3" class="pt10">
                            <input type="text" name="exam_start_time" value="<?php echo (!empty($search['exam_start_time'])) ? $search['exam_start_time'] :''; ?>" id="start_time" onfocus="var d5222 = $dp.$('end_time');
                                    WdatePicker({dateFmt: 'yyyy-MM-dd', onpicked: function() {
                                            d5222.focus();
                                        }, maxDate: '#F{$dp.$D(\'end_time\')}'})" class="fl w140 pt5 pr5 pb5 pl10 height20 border_c border_3 fontc_666 SipeiTime" />
                            <span class="fl pr5 pl5">至</span> 
                            <input type="text" name="exam_end_time" value="<?php echo (!empty($search['exam_end_time'])) ? $search['exam_end_time'] :''; ?>" id="end_time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'start_time\')}'})" class="fl w140 pt5 pr5 pb5 pl10 height20 border_c border_3 fontc_666 SipeiTime" />
                        </td>
                        <td align="right" class="pt10 pr3">状态：</td>
                        <td colspan="2" class="pt10">                            
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter select_shelter2"> 
                                    <select class="fl fontc_666" name="exam_status">
                                        <option value="0">请选择</option>
                                        <option value="2" <?php echo (!empty($search['exam_status']) && $search['exam_status'] == 2) ? 'selected' : '';?>>上传数据</option>
                                        <option value="1" <?php echo (!empty($search['exam_status']) && $search['exam_status'] == 1) ? 'selected' : '';?>>归档</option>
                                        <option value="3" <?php echo (!empty($search['exam_status']) && $search['exam_status'] == 3) ? 'selected' : '';?>>阅卷</option>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" style="margin-right:30px;" onclick="add();" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                        <th width="33" align="center" class="m_hr_t m_hr_b pl10"><input type="checkbox" class="checkboxs"></th>
                        <th width="76" align="left" class="m_hr_t m_hr_b pl10">学年</th>
                        <th width="112" align="center" class="m_hr_t m_hr_b">学期</th>
                        <th width="135" align="center" class="m_hr_t m_hr_b">考试日期</th>
                        <th width="111" align="center" class="m_hr_t m_hr_b">项目名称</th>
                        <th width="96" align="center" class="m_hr_t m_hr_b">年级</th>
                        <th width="110" align="center" class="m_hr_t m_hr_b">状态</th>
                        <th width="105" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="center" class="m_hr_b pl10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['exam_id'];?>" class="checkbox"></td>
                                <td align="left" class="m_hr_b pl10 height20 pt5 pb5"><?php echo $value['exam_term']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pb5"><?php echo $value['exam_term_sx']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pb5"><?php echo date('Y/m/d', $value['exam_start_time']); ?>~<?php echo date('Y/m/d', $value['exam_end_time']); ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pb5"><?php echo $value['exam_name']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pb5"><?php echo $value['grade_name']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $exam_status[$value['exam_status'] + 1]; ?></td>
                                <td align="center" class="m_hr_b">
                                <?php if ($value['exam_status']!=0):?>
                                    <img src="/themes/default/images/Sipei/edit.png" class="mr10 cursor" title="编辑" onclick="update(<?php echo $value['exam_id']; ?>);"/>
                                    <img src="/themes/default/images/Sipei/delate.png" class="cursor" onclick="set_ok(<?php echo $value['exam_id']; ?>)" title="删除"/>
                                    <?php endif;?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="8" align="center" class="fontw_bold">暂无数据</td>
                        </tr>
                    <?php endif; ?>	
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>

<script>
function set_ok(exam_id) {

	$.dialog.confirm('确定删除吗', function() {
		$.get('/exam/default/delete_all', {exam_id: exam_id}, function(data) {
			location.reload();

		});
	});
}
function delete_all(){
	var aa='';
	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
		aa+=$(this).val()+',';
	});
	if(aa == ''){
		$.dialog.alert("请选择要删除条目");
		return false;
	}
	$.dialog.confirm('确定删除所选数据吗', function() {
		aa+=0;

		$.get('/exam/default/delete_all', {exam_id: aa}, function(data) {
			location.reload();

		});
	});
}

function add() {
	// window.location.href = "<?php echo $this->createUrl('add'); ?>";
	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding: 0,
		fixed: true,
		title: "新增",
		width: 600,
		height: 500,
		max: false,
		min: false
	});
	$.get('/exam/default/add', function(html) {
		api.content(html);
	});
}

function update(exam_id) {

	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding: 0,
		fixed: true,
		title: "编辑",
		width: 600,
		height: 500,
		max: false,
		min: false
	});
	$.get('/exam/default/update', {exam_id: exam_id,time:new Date()}, function(html) {
		api.content(html);
	});
}

$(function() {
	$(".checkboxs").click(function() {
		var checkedS = $(this).attr("checked");
		if (checkedS) {
			$(".checkbox").attr("checked", true)
		} else {
			$(".checkbox").removeAttr("checked")
		}
	})

})



</script>
